<?php
class FileSystem {

    private static $errors;
    public static $success = true;

    public static function createDir($directoryName, $mode = 0777) {
        if (!file_exists($directoryName) && !mkdir($directoryName, $mode)) {
            $errors[] = $directoryName . ' is not exist.';
            self::$success = false;
        }//end if

        if (!is_writable($directoryName) && !chmod($directoryName, $mode)) {
            $errors[] = $directoryName . ' is not writable';
            self::$success = false;
        }//end if
        return self::$success;
    }

    public static function createFile($fileName, $mode = 0777) {
        if (!$handle = fopen($fileName, 'w')) {
            $errors[] = "Cannot open file '" . $fileName . "'";
            self::$success = false;
            fclose($handle);
        }//end if else

        if (!is_writable($fileName) && !chmod($fileName, $mode)) {
            $errors[] = "The file " . $fileName . " is not writable";
            self::$success = false;
        }//end if

        return self::$success;
    }

    public static function getErrors() {
        return self::$errors;
    }

}//end class